#include "..\include\LogInDlg.h"

//(*InternalHeaders(CLogInDlg)
#include <wx/xrc/xmlres.h>
//*)

//(*IdInit(CLogInDlg)
//*)

BEGIN_EVENT_TABLE(CLogInDlg,wxDialog)
	//(*EventTable(CLogInDlg)
	//*)
END_EVENT_TABLE()

CLogInDlg::CLogInDlg(wxWindow* parent, wxString& UserName, wxString& Password, bool& SaveInfo)
{
	//(*Initialize(CLogInDlg)
	wxXmlResource::Get()->LoadObject(this,parent,_T("CLogInDlg"),_T("wxDialog"));
	StaticText1 = (wxStaticText*)FindWindow(XRCID("ID_STATICTEXT1"));
	StaticText2 = (wxStaticText*)FindWindow(XRCID("ID_STATICTEXT2"));
	TextCtrl1 = (wxTextCtrl*)FindWindow(XRCID("ID_TEXTCTRL1"));
	StaticText3 = (wxStaticText*)FindWindow(XRCID("ID_STATICTEXT3"));
	TextCtrl2 = (wxTextCtrl*)FindWindow(XRCID("ID_TEXTCTRL2"));
	CheckBox1 = (wxCheckBox*)FindWindow(XRCID("ID_CHECKBOX1"));
	StaticLine1 = (wxStaticLine*)FindWindow(XRCID("ID_STATICLINE1"));
	Button1 = (wxButton*)FindWindow(XRCID("idBTN_OK"));
	Button2 = (wxButton*)FindWindow(XRCID("idBTN_CANCEL"));
	//*)

	// attach validators
    TextCtrl1->SetValidator(wxTextValidator(wxFILTER_NONE, &UserName) );
    TextCtrl2->SetValidator(wxTextValidator(wxFILTER_NONE, &Password) );
    CheckBox1->SetValidator(wxGenericValidator(&SaveInfo) );
}

CLogInDlg::~CLogInDlg()
{
	//(*Destroy(CLogInDlg)
	//*)
}


void CLogInDlg::OnInit(wxInitDialogEvent& event)
{
}

void CLogInDlg::OnBtnOK(wxCommandEvent& event)
{
    if (Validate() && TransferDataFromWindow() )
    {
        if (IsModal() )
            EndModal(wxID_OK);
        else
        {
            SetReturnCode(wxID_OK);
            this->Show(false);
        }
    }
}

void CLogInDlg::OnBtnCancel(wxCommandEvent& event)
{
    if (IsModal() )
        EndModal(wxID_CANCEL);
    else
    {
        SetReturnCode(wxID_CANCEL);
        this->Show(false);
    }
}
